<?php
namespace Admin\Controller;

use Think\Controller;

class UploadController extends Controller
{
    //上传我的图片
    public function Upload()
    {
        $type = $_FILES['logo']['type'];
        // 判断类型
        if (strstr($type, 'image/jpeg')) {
            $ext = '.jpg';
        } elseif (strstr($type, 'image/png')) {
            $ext = '.png';
        } elseif (strstr($type, 'image/gif')) {
            $ext = '.gif';
        } else {
            echo '不支持此类型文件';
            exit();
        }
        //生成文件名
        $name = time() . rand(100, 999) . $ext;
        //保存图片路径
        $path = './Upload/'.$name;
        if(move_uploaded_file($_FILES['logo']['tmp_name'],$path)){
            echo $path;
        }else{
            echo 0;
        }

    }
}
